/*
 * Copyright (c) 2022.版权所有高金磊
 */

package 领扣算法.A简单题.对奇偶下标分别排序;

import java.util.ArrayList;
import java.util.Collections;

public class Main {
    public int[] sortEvenOdd(int[] nums) {
        ArrayList<Integer> data1=new ArrayList<>(),data2=new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            if (i%2==0){
                data2.add(nums[i]);
            }
            else
                data1.add(nums[i]);
        }
        Collections.sort(data1, (a,b)->(b-a));
        Collections.sort(data2);
        for (int i = 0; i < nums.length; i++) {
            if (i%2==0){
                nums[i]=data2.get(i/2);
            }
            else {
                nums[i]=data1.get(i/2);
            }
        }
        return nums;
    }
}
